package model;

/**
 * Represents a user for the UrbanParks system. Users can be staff member, park
 * manager or volunteer.
 * 
 * @author Ahmed Abdul-Rahman (aabdulr@gmail.com)
 * @version Winter 2012.
 * 
 */
public class User {

  private String my_user_name;

  private String my_user_email;

  private Role my_user_role;

  /**
   * Constructor.
   * 
   * @param the_user_name
   * 
   * @param the_user_email
   * 
   * @param the_user_role
   * 
   */
  public User(String the_user_name, String the_user_email, Role the_user_role) {
    my_user_name = the_user_name;
    my_user_email = the_user_email;
    my_user_role = the_user_role;
  }

  /**
   * No argument constructor.
   */
  public User() {
  }

  /**
   * Sets a user's name.
   * 
   * @param the_user_name
   * 
   */
  public void setUserName(final String the_user_name) {
    my_user_name = the_user_name;
  }

  /**
   * Gets and returns a user's name.
   * 
   * @return a user's name.
   */
  public String getUserName() {
    return my_user_name;
  }

  /**
   * Sets a user's email address.
   * 
   * @param the_user_email
   * 
   */
  public void setUserEmail(final String the_user_email) {
    my_user_email = the_user_email;
  }

  /**
   * Gets and returns a user's email address.
   * 
   * @return a user's email address.
   */
  public String getUserEmail() {
    return my_user_email;
  }

  /**
   * Sets a user's role.
   * 
   * @param the_user_role
   *          a user's role.
   */
  public void setUserRole(final Role the_user_role) {
    my_user_role = the_user_role;
  }

  /**
   * Gets and returns the role associated with a user.
   * 
   * @return a user's role.
   */
  public Role getUserRole() {
    return my_user_role;
  }

  @Override
  public boolean equals(Object the_other_user) {
    boolean result = false;
    if (the_other_user != null && the_other_user.getClass() == this.getClass()) {
      String email = ((User) the_other_user).getUserEmail();
      if (this.getUserEmail() == email) {
        result = true;
      }
    }
    return result;

  }

  /**
   * Gets haschcode.
   * 
   * @return the hashcode of email string.
   */
  public int getHashcode() {
    return getUserEmail().hashCode();
  }

}
